/**
 * 交易分析
 */
import api from '../../../api';
import { message } from 'antd';
export default {
  namespace: 'tradeAnalysisM',

  state: {},

  effects: {
    // 获取交易统计信息
    *getTradeCount({ payload, callback }, { call, put }) {
      const response = yield call(api.profitOverview.getTradeCount, payload);

      if (response && response.code === 0) {
        callback(response.data);
      } else {
        callback();
        message.error((response && response.msg) || '获取交易统计信息失败');
        console.error(`获取交易统计信息失败，失败原因：${response?.msg}`, 'tradeCount 接口：tradeanalysis/tradeCount');
      }
    },
  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
